package cn.com.zh.app.userManager.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.com.zh.app.common.util.ResultVO;
import cn.com.zh.app.userManager.dto.AdminUserInfoDTO;
import cn.com.zh.app.userManager.form.AdminUserForm;
import cn.com.zh.app.userManager.service.AdminUserInfoService;

@RestController
public class AdminUserInfoController {

	private Logger logger = LoggerFactory.getLogger(UserInfoController.class);
	
	@Resource
	private AdminUserInfoService adminUserInfoService;
	
	@RequestMapping("/adminLogin")
	public ResultVO<Object> adminLogin(HttpServletRequest request, HttpServletResponse response,AdminUserForm form){
		logger.info("传入的参数的值为:",form.toString());
		ResultVO<Object> vo=new ResultVO<Object>();
		AdminUserInfoDTO adminDto=new AdminUserInfoDTO();
		adminDto.setAdminCode(form.getAdminCode());
		adminDto.setAdminPass(form.getAdminPass());
		try {
			AdminUserInfoDTO adminInfo=adminUserInfoService.queryAdminUsedrInfo(adminDto);
			if(adminInfo !=null) {
				vo.setCode("000000");
				vo.setBody(adminInfo);
				vo.setMessage("success");
			}else {
				vo.setCode("100000");
				vo.setMessage("登录失败");
			}
		}catch(Exception e) {
			vo.setCode("999999");
			vo.setMessage("系统异常");
		}
		return vo;
	}
}
